package light.head.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

/**
 *  商品信息表
 */
@Entity
@Table
public class Commodity implements Serializable {
	private static final long serialVersionUID = 5896399525384732309L;
	private Integer code;						// 流水号
	private Integer oc;							// 公司编号
	private String name;						// 商品名称
	private String brand;						// 品牌
	private String norms;						// 规格
	private String content;						// 具体详情
	private Integer cc;							// 商品类型编号
	private Integer cu;							// 创建人
	private Date ct;							// 创建时间
	private String price;						// 产品单价
	private Boolean deleted = false;			// 是否删除
	private String categoryName;				// 类型名称
	private String organName;					// 公司名称
	private List<CommodityImg> list;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column(updatable = false)
	public Integer getOc() {
		return oc;
	}
	@Column(length = 200)
	public String getName() {
		return name;
	}
	@Column(length = 200)
	public String getBrand() {
		return brand;
	}
	@Column(length = 200)
	public String getNorms() {
		return norms;
	}
	@Column
	public Integer getCc() {
		return cc;
	}
	
	@Column
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public String getPrice() {
		return price;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Formula("(SELECT c.name FROM Category c WHERE c.code = cc)")
	public String getCategoryName() {
		return categoryName;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOrganName() {
		return organName;
	}
	@Transient
	public String getContent() {
		return content;
	}
	@Transient
	public List<CommodityImg> getList() {
		return list;
	}
	
	
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setBrand(String brand) {
		this.brand = brand;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public void setNorms(String norms) {
		this.norms = norms;
	}
	public void setCc(Integer cc) {
		this.cc = cc;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	
	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}
	public void setOrganName(String organName) {
		this.organName = organName;
	}
	public void setList(List<CommodityImg> list) {
		this.list = list;
	}
}
